package com.wuli.auth.common.model;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

public class R<T> implements Serializable {
    private static final long serialVersionUID = -7367235372616638542L;

    @ApiModelProperty("请求是否成功")
    public boolean success;
    @ApiModelProperty("返回结果提示")
    public String message;
    @ApiModelProperty("返回结果码.0为正常")
    public int code;
    @ApiModelProperty("返回结果数据")
    public T data;

    public R<T> Error(String message)
    {
        this.success  = false;
        this.code = -1;
        this.message = message;
        return this;
    }

    public R<T> Success(T result)
    {
        this.success  = true;
        this.code = 0;
        this.message = "";
        this.data = result;
        return this;
    }

    public R<T> Success()
    {
        this.success  = true;
        this.code = 0;
        this.message = "";
        this.data = null;
        return this;
    }

}
